/*
 * @isVip: 是否为 vip
 * @bacIcon: 白夜背景的切换入口
 * @flagIcon: 国旗icon
 * @yanHuaIcon: 烟花icon
 *  */
import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    bacIcon: require("@/assets/img/白天-默认.png"),
    flagIcon: require("@/assets/img/国旗.png"),
    yanHuaIcon: require("@/assets/img/烟花.png"),
    isVip: !false,
    flagOpen: false,
    yanHuaOpen: false,
    startTime: localStorage.getItem("start") || new Date().getTime(),
    pandaSty: [
      {
        _id: 0,
        icon: require("@/assets/img/night.png"),
        tips: "夜晚",
        isActive: false,
        focus: (it) => {
          let that = it;
          that.$store.state.bacIcon = require("@/assets/img/黑夜-默认.png");
        },
        before: (it) => {
          let that = it;
          that.$store.state.bacIcon = require("@/assets/img/白天-默认.png");
        },
      },
      {
        _id: 1,
        icon: require("@/assets/img/flag.png"),
        tips: "国旗",
        isActive: false,
        focus: (it) => {
          let that = it;
          that.$store.state.flagOpen = true;
        },
        before: (it) => {
          let that = it;
          that.$store.state.flagOpen = false;
        },
      },
      {
        _id: 2,
        icon: require("@/assets/img/yanhua.png"),
        tips: "烟花",
        isActive: false,
        focus: (it) => {
          let that = it;
          that.$store.state.yanHuaOpen = true;
        },
        before: (it) => {
          let that = it;
          that.$store.state.yanHuaOpen = false;
        },
      },
      {
        _id: 3,
        icon: require("@/assets/img/cap.png"),
        tips: "兔子头套",
        isActive: false,
        focus: (it) => {
          let that = it;
          that.$store.state.yanHuaOpen = true;
        },
        before: (it) => {
          let that = it;
          that.$store.state.yanHuaOpen = false;
        },
      },
      {
        _id: 4,
        icon: require("@/assets/img/moom.png"),
        tips: "中秋月圆",
        isActive: true,
        focus: (it) => {
          let that = it;
          alert(666);
        },
        before: (it) => {
          let that = it;
          alert(111);
        },
      },
    ],
  },
  /**
   * @method: toggleNightDay
   * @param: [Obj] state: 作用域 元素
   */
  mutations: {
    toggleNightDay(state) {
      state.bacIcon = require("@/assets/img/黑夜-默认.png");
    },
    /**
     * @method: commitSave ：
     * @param: [Obj] decorationArr: 熊猫装扮 数据
     */
    commitSave(state, data) {
      // console.log("熊猫", data.decorationArr);
      console.log("666666", JSON.parse(localStorage.getItem("pandaDecration")));
    },
  },
  actions: {},
  modules: {},
});
